import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import vueJsxPlugin from "@vitejs/plugin-vue-jsx";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [vue(),vueJsxPlugin()],
  resolve: {
    alias: {
      "@": path.resolve("./src") ,
    },
  },
  css: {
    // CSS 预处理器
    preprocessorOptions: {
      scss: {
        additionalData: `@import './src/style/globalVar.scss';`,
      }
    }
  },
  server: {
    proxy: {
      '/api': {
        target: "http://127.0.0.1:2345",
        changeOrigin: true,
        rewrite: path => path.replace(/^\/api/, '')
      }
    }
  },
  build: {
    rollupOptions: {
      output: {
        // 在这里修改静态资源路径
        chunkFileNames: 'assets/js/[name]-[hash].js',
        entryFileNames: 'assets/js/[name]-[hash].js',
        assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
      }
    }
  },
})
